
package org.upt.dcda.webservices;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.jboss.resteasy.logging.Logger;
import org.upt.dcda.AuthorManager;
import org.upt.dcda.AuthorManagerBeanRemote;
import org.upt.dcda.BookManager;
import org.upt.dcda.BookManagerBeanRemote;
import org.upt.dcda.SearchManager;
import org.upt.dcda.SearchManagerBeanRemote;

import com.google.gson.Gson;

public abstract class CommonService
{

	protected final Logger	logger	= Logger.getLogger(this.getClass());

	protected final Gson	gson	= new Gson();

	protected AuthorManagerBeanRemote getAuthorManagerBean() throws NamingException
	{
		InitialContext initContext = new InitialContext();
		AuthorManagerBeanRemote bean = (AuthorManagerBeanRemote) initContext.lookup(AuthorManager.AUTHOR_BEAN_NAME);
		return bean;
	}

	protected BookManagerBeanRemote getBookManagerBean() throws NamingException
	{
		InitialContext initContext = new InitialContext();
		BookManagerBeanRemote bean = (BookManagerBeanRemote) initContext.lookup(BookManager.BOOK_BEAN_NAME);
		return bean;
	}

	protected SearchManagerBeanRemote getSearchManagerBean() throws NamingException
	{
		InitialContext initContext = new InitialContext();
		SearchManagerBeanRemote bean = (SearchManagerBeanRemote) initContext.lookup(SearchManager.SEARCH_BEAN_NAME);
		return bean;
	}
}
